﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/AdminSchedule.master" AutoEventWireup="true" CodeFile="RouteEdit.aspx.cs" Inherits="Pages_RouteEdit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" Runat="Server">
	<style type="text/css">
		.edit-form { overflow: hidden; clear: both;}
		.edit-row { width: 500px; margin: 0px auto;}
		.edit-label { width: 200px; float:left;}
		.edit-control { width: 300px; float: left;}
		.ui-modal-overlay 
		{
			background-color: Black;
			filter: alpha(opacity=50);
			opacity: .5;
		}
		.modaldiv
		{
			overflow: hidden;
			border: solid 2px black;
			padding: 5px;
		}
	</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" Runat="Server">
	<div>
		<a href='<%= ResolveUrl("~/Pages/Route.aspx") %>'>Вернуться к списку маршрутов</a>
	</div>
	<div class="edit-form">
		<div class="edit-row">
			<div class="edit-label">Название маршрута</div>
			<div class="edit-control">
				<asp:TextBox runat="server" ID="tbRouteName" />
			</div>
		</div>
		<asp:UpdatePanel runat="server" ID="upRoute" UpdateMode="Conditional">
			<ContentTemplate>
				<div class="edit-row">
					<div class="edit-label">Остановка отправления</div>
					<div class="edit-control">
						<asp:Label runat="server" ID="lbSourceStation" />
						<asp:HiddenField runat="server" ID="hfSourceStation" />
						<asp:LinkButton runat="server" ID="lkbEditSourceStation" Text="[Изменить]" 
										OnClick="OnEditStation" CommandName="SourceStation" />
					</div>
				</div>
				<div class="edit-row">
					<div class="edit-label">Остановка прибытия</div>
					<div class="edit-control">
						<asp:Label runat="server" ID="lbTargetStation" />
						<asp:HiddenField runat="server" ID="hfTargetStation" />
						<asp:LinkButton runat="server" ID="lkbEditTargetStation" Text="[Изменить]" 
										OnClick="OnEditStation" CommandName="TargetStation" />
					</div>
				</div>
				<div class="edit-row">
					<div class="edit-label">Промежуточные остановки</div>
					<div class="edit-control">
						<asp:Repeater runat="server" ID="rptRouteStation">
							<ItemTemplate>
								<%# string.Format("{0} ({1})", Eval("Station_name"), Eval("Distance"))%>
								<asp:LinkButton runat="server" ID="lkbEditRouteStation" Text="[Удалить]" CommandArgument='<%# Eval("Station_id") %>'
												OnClick="OnDeleteStation" />
								<br />
							</ItemTemplate>
						</asp:Repeater>
						<asp:LinkButton runat="server" ID="lkbAddRouteStation" Text="Добавить" 
										OnClick="OnEditStation" CommandName="RouteStation" />
						<asp:LinkButton runat="server" ID="lbEditDistances" Text="Редактировать расстояния" OnClick="lbEditDistances_Click" />
					</div>
				</div>
			</ContentTemplate>
		</asp:UpdatePanel>
	</div>
	<div style="text-align:center;">
		<asp:Button runat="server" ID="btnSave" Text="Сохранить" OnClick="OnRouteSave" />
		<asp:Button runat="server" ID="btnCancel" Text="Отменить" PostBackUrl='<%= ResolveUrl("~/Pages/Route.aspx") %>' />
	</div>
	
	<div id="modal" runat="server" class="modaldiv" style="display: none;">
		<asp:UpdatePanel runat="server" ID="upStation">
			<ContentTemplate>
				<asp:TextBox runat="server" ID="tbSearchStation" Width="250" AutoPostBack="true"
							OnTextChanged="OnSearchStation" />
				<asp:LinkButton runat="server" ID="lkbAddNewStation" Text="Добавить"
								OnClick="OnAddNewStation" />
				<br />
				<asp:Repeater runat="server" ID="rptStation">
					<ItemTemplate>
						<asp:LinkButton runat="server" ID="lkbStation" Text='<%# Eval("Name") %>'
										CommandArgument='<%# Eval("Id") %>' OnClick="AddStation" />
					</ItemTemplate>
				</asp:Repeater>
				<asp:HiddenField runat="server" ID="hfModalAction" />
			</ContentTemplate>
		</asp:UpdatePanel>
		<div style="text-align: right;">
			<asp:Button runat="server" ID="btnModalClose" Text="Закрыть" />
		</div>
	</div>
	<asp:LinkButton Text="" runat="server" ID="lnkPopup" />
	<%--<ajax:ModalPopupExtender ID="MPE" runat="server" PopupControlID="modal" TargetControlID="lnkPopup"
		CancelControlID="btnModalClose" BehaviorID="MPEbeh" BackgroundCssClass="ui-modal-overlay"
		OkControlID="btnModalClose" />--%>
</asp:Content>

